package me.luger.project.fof.entity;


import com.alibaba.druid.support.json.JSONUtils;
import me.luger.core.commom.util.JsonUtil;
import me.luger.core.dao.nutz.entity.BaseEntity;
import me.luger.project.fof.entity.ext.TaskParams;
import org.nutz.dao.entity.annotation.*;
import com.alibaba.fastjson.annotation.JSONField;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Table("fof_task")
public class FofTask extends BaseEntity implements Serializable{
private static final long serialVersionUID=1L;

    public static enum TASK_STATUS{
        INIT(1,"初始化"),RUNNING(2,"执行中"),SUCESS(3,"成功完成任务"),FAIL(-1,"任务失败");
        private Integer statusId;
        private String info;

        TASK_STATUS(Integer statusId,String info){
            this.statusId = statusId;
            this.info = info;
        }
        public int status(){
            return this.statusId;
        }
    }


    /**
     * 自动递增ID
     */
    @Id
    @Column("id")
    @Comment("自动递增ID")
    @ColDefine(type = ColType.INT, width = 10)
    private Integer id;
    /**
     * 任务ID
     */
    @Column("taskId")
    @Comment("任务ID")
    @ColDefine(type = ColType.VARCHAR, width = 64)
    private String taskId;
    /**
     * 任务类型1：收益风险 
     */
    @Column("type")
    @Comment("任务类型1：收益风险 ")
    @ColDefine(type = ColType.INT, width = 3)
    private Integer type;
    /**
     * 当前任务状态1：初始化 2：执行中 3：成功完成任务 -1：任务失败
     */
    @Column("status")
    @Comment("当前任务状态1：初始化 2：执行中 3：成功完成任务 -1：任务失败")
    @ColDefine(type = ColType.INT, width = 3)
    private Integer status;

    /**
     * 参数json格式
     */
    @Column("params")
    @Comment("参数json格式")
    @ColDefine(type = ColType.VARCHAR, width = 2048)
    private String params;
    /**
     * 开始时间
     */
    @Column("startTime")
    @Comment("开始时间")
    @ColDefine(type = ColType.DATETIME, width = 19)
    @JSONField (format="yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    /**
     * 最后更新时间
     */
    @Column("updateTime")
    @Comment("最后更新时间")
    @ColDefine(type = ColType.DATETIME, width = 19)
    @JSONField (format="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 输入数据路径
     */
    @Column("dataDir")
    @Comment("输入数据路径")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String dataDir;

    /**
     * 执行信息
     */
    @Column("msg")
    @Comment("输入数据路径")
    @ColDefine(type = ColType.TEXT)
    private String msg;

    /**
     * 业务串行ID
     */
    @Column("bizId")
    @Comment("业务串行ID")
    @ColDefine(type = ColType.VARCHAR)
    private String bizId;

    /**
     * 资产/策略配置结果
     */
    @Column("assetStrategyResult")
    @Comment("资产/策略配置结果")
    @ColDefine(type = ColType.VARCHAR)
    private String assetStrategyResult;



    public void setId(Integer id){
        this.id=id;
    }
    public Integer getId(){
        return this.id;
    }

    public void setTaskId(String taskId){
        this.taskId=taskId;
    }
    public String getTaskId(){
        return this.taskId;
    }

    public void setType(Integer type){
        this.type=type;
    }
    public Integer getType(){
        return this.type;
    }

    public void setStatus(Integer status){
        this.status=status;
    }
    public Integer getStatus(){
        return this.status;
    }

    public void setStartTime(Date startTime){
        this.startTime=startTime;
    }
    public Date getStartTime(){
        return this.startTime;
    }

    public void setUpdateTime(Date updateTime){
        this.updateTime=updateTime;
    }
    public Date getUpdateTime(){
        return this.updateTime;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getParams() {
        return params;
    }

    public TaskParams getTaskParams(){
        return JsonUtil.parse(this.getParams(), TaskParams.class);
    }

    public void setParams(String params) {
        this.params = params;
    }

    public String getDataDir() {
        return dataDir;
    }

    public void setDataDir(String dataDir) {
        this.dataDir = dataDir;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getBizId() {
        return bizId;
    }

    public void setBizId(String bizId) {
        this.bizId = bizId;
    }

    public String getAssetStrategyResult() {
        return assetStrategyResult;
    }

    public void setAssetStrategyResult(String assetStrategyResult) {
        this.assetStrategyResult = assetStrategyResult;
    }
}